home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJINC106.ARJ / STDARG.H < prev    next >
C/C++ Source or Header  |  1992-03-09  |  2KB  |  70 lines

  1. /* This is file stdarg.h */
  2. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  3. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  4. ** Rochester NH, 03867-2954, USA.
  5. */
  6.  
  7. /* This may look like C code, but it is really -*- C++ -*- */
  8.  
  9. /* 
  10. Copyright (C) 1988 Free Software Foundation
  11.  
  12. This file is part of GNU CC.
  13.  
  14. GNU CC is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY.  No author or distributor
  16. accepts responsibility to anyone for the consequences of using it
  17. or for whether it serves any particular purpose or works at all,
  18. unless he says so in writing.  Refer to the GNU CC General Public
  19. License for full details.
  20.  
  21. Everyone is granted permission to copy, modify and redistribute
  22. GNU CC, but only under the conditions described in the
  23. GNU CC General Public License.   A copy of this license is
  24. supposed to have been given to you along with GNU CC so you
  25. can know your rights and responsibilities.  It should be in a
  26. file named COPYING.  Among other things, the copyright notice
  27. and this notice must be preserved on all copies.  
  28. */
  29.  
  30. #ifndef _stdarg_h
  31. #define _stdarg_h 1
  32.  
  33. #ifndef __GNUC__
  34. #ifdef __cplusplus
  35. extern "C" __builtin_saveregs ();
  36. #else
  37. extern __builtin_saveregs ();
  38. #endif
  39. #endif
  40.  
  41. typedef char *va_list;
  42.  
  43. /* Amount of space required in an argument list for an arg of type TYPE.
  44.    TYPE may alternatively be an expression whose type is used.  */
  45.  
  46. #define __va_rounded_size(TYPE)  \
  47.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  48.  
  49. #if     defined(sparc)
  50. #  define va_start(AP, LASTARG)                                         \
  51.  (__builtin_saveregs (), AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
  52. #elif defined(mips)
  53. #  define va_start(AP,LASTARG) {\
  54.        static char __vd_alist[16] = "__%%VARARGS";  /* Identify to codegen */\
  55.         __builtin_saveregs();\
  56.         (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)));}
  57. #else
  58. #  define va_start(AP, LASTARG)                                         \
  59.  (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
  60. #endif
  61.  
  62. void va_end (va_list);          /* Defined in gnulib */
  63. #define va_end(AP)
  64.  
  65. #define va_arg(AP, TYPE)                                                \
  66.  (AP += __va_rounded_size (TYPE),                                       \
  67.   *((TYPE *) (AP - __va_rounded_size (TYPE))))
  68.  
  69. #endif
  70.